package com.buildings.http;

import com.google.gson.internal.$Gson$Types;

import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import okhttp3.Call;

/**
 * Created by songwei on 2017/3/6.
 */

public abstract class BaseCallBack<T> {

    static Type getSuperclassTypeParameter(Class<?> subclass){
        Type superclass = subclass.getGenericSuperclass();
        if (superclass instanceof Class){

            return null;
        }
        ParameterizedType parameterizedType = (ParameterizedType) superclass;
        return $Gson$Types.canonicalize(parameterizedType.getActualTypeArguments()[0]);
    }


    public Type mType;


    public BaseCallBack(){

        mType = getSuperclassTypeParameter(this.getClass());
    }


    public void onSuccess(T t){}

    public void onError(int code){}

    public void onFailure(Call call, IOException e){}


}
